function addToCart(product_id, quantity) {
    quantity = typeof(quantity) != 'undefined' ? quantity : 1;

    $.ajax({
        url: 'index.php?route=module/cart/add',
        type: 'post',
        data: 'product_id=' + product_id + '&quantity=' + quantity,
        dataType: 'json',
        success: function(json) {
            if (json['success']) {
                $('#cart_total').html(json['total_items']);
            }
        }
    });
}

function removeFromCart(product_key, redirect) {

}

function updateCart(product_key, quantity_id, redirect) {
    
}

function isValidEmail(email){
    var mail_pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z]{1,6})+$/;

    return mail_pattern.test(email);
}

function showMessage(message){
    alert(message);
}

$(function() {
    //JS Hiden/Show button Delete CART PAGE
    var currentlyOpen = null;
    $("#content").on('click', '.wrapDec, .wrapImg', function() {
        var wrapDelete = $(this).parent().find('.wrapDelete').closest('.wrapDelete');

        if(currentlyOpen && currentlyOpen.get(0) === wrapDelete.get(0)) {
            wrapDelete.animate({right: '-20%'}, 100);
            currentlyOpen = null;
        } else {
            if(currentlyOpen){
                currentlyOpen.animate({right: '-20%'}, 100);
            }
            wrapDelete.animate({right: '0'}, 100);
            currentlyOpen = wrapDelete;
        }
    });

    //JS CART PAGE
    $(".bntAdd").click(function(){
        $(this).parent().find(".bntAdd ").addClass("added");
    });
});